﻿using CefSharp;
using CefSharp.Handler;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BaseFrame.Tool.CefSharp
{
    /// <summary>
    /// 自定义获取请求资源数据封装
    /// </summary>
    public class MyRequestGetCustomUrlHandler: RequestHandler
    {
        protected override IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame,
          IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling)
        {
            if (request.Url.Contains("请求资源的url") || request.Url.Contains("请求资源的url"))
            {
                return new CustomResourceResourceRequestHandler();
            }

            // 先调用基类的实现，断点调试
            return base.GetResourceRequestHandler(
                chromiumWebBrowser, browser, frame, request, isNavigation,
                isDownload, requestInitiator, ref disableDefaultHandling);
        }
    }
}
